using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_CuaHangThem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadDropDownList();
        }
    }
    private void LoadDropDownList()
    {
        tbSanPhamCollection spCollection = tbSanPhamBUS.GetAll();
        ddl_sanpham.DataTextField = tbSanPhamColumns.TenSP.ToString();
        ddl_sanpham.DataValueField = tbSanPhamColumns.MaSP.ToString();
        ddl_sanpham.DataSource = spCollection;
        ddl_sanpham.DataBind();
        ddl_sanpham.Items .Insert (0,new ListItem ("All","0"));
    }

    protected void btn_Add_Click(object sender, EventArgs e)
    {
        try
        {
            tbCuaHang cuahang = new tbCuaHang();
            cuahang.TenCH = txt_tencuahang.Text;
            cuahang.SanPham = int.Parse(ddl_sanpham.SelectedValue);
            tbCuaHangBUS.Insert(cuahang);
            Response.Redirect("~/Admin/CuaHangDanhSach.aspx");
        }
        catch (Exception ex)
        {
        }
        Response.Redirect("~/Admin/CuaHangDanhSach.aspx");
    }
}
